/**
 * 实现爆炸
 * 创建者：Carburn Ashroom
 * 2022.12.14
 */

#include "bomb.h"

#include "sound.h"

namespace Bomb {

    void Bomb::draw_this(QPixmap *pix) const
    {
        QPainter painter {pix};
        painter.drawPixmap(pos, pixmap);
    }

    bool Bomb::update()
    {
        if (interval-- == 0) {
            interval = bomb_interval;
            if (temp_index++ == bomb_count)
                return true;
            else
                pixmap = QPixmap{bomb_path.arg(temp_index)};
        }
        return false;
    }

    void Bomb::set_pos(QPoint center)
    {
        Sound::Effect bomb_sound;
        bomb_sound.play();
        center -= QPoint{pixmap.width()/2,pixmap.height()/2};
        pos = center;
    }

}
